#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 1e5+50;

int n, a[N];


int pre[N], suf[N], ans[N];

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for (int i=0; i<n; ++i)
		scanf("%d", &a[i]);


	pre[0] = ~a[0];
	for (int i=1; i<n; ++i)
	{
		pre[i] = pre[i-1] & (~a[i]);
	}

	suf[n-1] = ~a[n-1];
	for (int i=n-2; i>=0; --i)
	{
		suf[i] = suf[i+1] & (~a[i]);
	}
	int ansp = -1;
	for (int i=0; i<n; ++i)
	{
		int p = a[i];
		dbg(p);
		if (i > 0) p &= pre[i-1];
		if (i < n-1) p &= suf[i+1];
		// ans = max(ans, p);
		ans[i] = p;
		if (ansp == -1 || ans[ansp] < p)
		{
			ansp = i;
		}
	}
	// printf("%d\n", ans[ansp]);
	printf("%d", a[ansp]);
	for (int i=0; i<n; ++i)
		if (i != ansp)
			printf(" %d", a[i]);
	putchar('\n');
	return 0;
}